﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using myBoard.Framework.Controls.Navigation;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using System.Collections;
using myTwitter.CustomControls;
using System.Windows;

namespace myTwitter.BO
{
    public class Tweets : ObservableCollection<IMessage>, IBreadcrumbExplorerEntity
    {
        IMessagesControl _iMessagesControl;

        public Tweets()
        { }
        public Tweets(IEnumerable<IMessage> list)
            : base(list)
        { }

        #region IBreadcrumbExplorerEntity Members

        public string Name { get; set; }

        public System.Windows.Media.Imaging.BitmapImage Icon { get; set; }

        
        public System.Windows.FrameworkElement GetControl()
        {
            _iMessagesControl = new IMessagesControl();
            _iMessagesControl.UserInfoRequested += iMessagesControl_UserInfoRequested;
            _iMessagesControl.DataContext = this;
            return _iMessagesControl;
        }       

        void iMessagesControl_UserInfoRequested(object sender, User u)
        {
            if (IBreadcrumbExplorerNextEntitySelected != null)
                IBreadcrumbExplorerNextEntitySelected(this, u);
        }

        public void Dispose()
        {
            if(_iMessagesControl!=null)
                _iMessagesControl.UserInfoRequested -= iMessagesControl_UserInfoRequested;
        }

        public void Update(object newValue)
        {}

        public event IBreadcrumbExplorerNextEntitySelectedHandler IBreadcrumbExplorerNextEntitySelected;

        #endregion
    }
}
